package com.pagepub.core.tag.validator;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;

public class ValidateEmpty extends FormValidateBasic {
	/**
	 * 
	 */
	private static final long serialVersionUID = -771462505873863737L;

	/**
	 * @param args
	 */

	@Override
	public int doStartTag() throws JspException {
		// TODO 自动生成方法存根
		JspWriter out = this.pageContext.getOut();

		try {
			out.print(validateempty());
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return 1;
	}

	public StringBuffer validateempty() {
		StringBuffer str = new StringBuffer();
		str.append("<script language=\"javascript\">");
		str.append("function Validateempty(realvalue,realname,spanname){");
		// str.append("alert(realname);");
		str.append(" var thisvalue=cTrim(realvalue,0);");

		str.append("var flag=0;");
		str.append("if(thisvalue==\"\"){");

		str.append("	message=\"对不起,\"+realname+\"不能为空！\";");
		str.append("    imgurl=\"<img src=\\\"" + this.getWrongimage()
				+ "\\\"/>\";");
		str.append(" flag=1;");
		str.append("}");
		str.append("if(flag==1){");
		str.append(this.display());
		str.append("return false;}");
		str.append("else { ");

		str.append(this.displayempty());
		str.append("return true;}");
		str.append("}");
		str.append("</script>");
		str.append(this.cTrim());
		return str;
	}
}
